package model

import (
	"time"

	"gorm.io/gorm"
)

// Permission 权限模型
type Permission struct {
	ID          uint           `gorm:"primarykey" json:"id"`
	UserID      uint           `gorm:"index;not null" json:"user_id"`       // 用户ID
	DirectoryID uint           `gorm:"index;not null" json:"directory_id"`  // 目录ID
	AccessType  string         `gorm:"size:20;not null" json:"access_type"` // 访问类型: read/write
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`

	// 关联关系
	User      *User      `gorm:"foreignKey:UserID" json:"user,omitempty"`
	Directory *Directory `gorm:"foreignKey:DirectoryID" json:"directory,omitempty"`
}
